<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script type="text/javascript">
    // 解构赋值的基本用法
        // let obj= {a:1,b:2,c:2}
        // let arr = [2,4,6,8,10]

        // 传统写法
        // const c=obj.c

        // 解构赋值
        // const {c} = obj;

        // 数组的解构赋值
        // const [c] = arr;   //const c = arr[0]
        // console.log(c);

        // const [,,a]=arr;
        // console.log(a);

    /***********************************/ 
        let obj={
            a:1,
            b:2,
            c:{
                x:1,
                y:2
            }
        }
        // 正常解构赋值
        // const {y} = obj.c;  //y=2   ==> const y=obj.c.y

        // 连续解构赋值
        // const {c:{y}} = obj //const y=obj.c.y
        // const {y}=obj  // y=undefined
        // console.log(y);
        // console.log(c);

        // 连续解构赋值+重命名
        const {c:{y:value}}=obj
        console.log(value);


    </script>
</body>
</html>